<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<meta http-equiv="Pragma" content="no-cache"> 
<meta http-equiv="Cache-Control" content="no-cache"> 
<meta http-equiv="Expires" content="0"> 
<title>体育与健康课程管理系统</title> 
<link href="${pageContext.request.contextPath}/public/css/login.css" type="text/css" rel="stylesheet"> 
    <script type="text/javascript" src="${pageContext.request.contextPath}/public/js/jquery-3.2.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/public/js/layer/layer.js"></script>
</head> 
<body> 

<div class="login">
    <div class="message">体育与健康课程管理系统-管理登录</div>
    <div id="darkbannerwrap"></div>
    
    <form id="myform">
		<input name="action" value="login" type="hidden">
		<input name="username" placeholder="用户名" required="" type="text">
		<hr class="hr15">
		<input name="password" placeholder="密码" required="" type="password">
		<hr class="hr15">
		<input value="登录" style="width:100%;" type="button" id="sub">
		<hr class="hr20">
	 帮助 <a onClick="alert('请联系管理员 ')">忘记密码</a> 
	</form>

	
</div>

<div class="copyright">技术支持：石河子大学软件开发部</div>

</body>
<script type="text/javascript">
    $('#sub').click(function ()
        {
            var username=$('input[name=username]');
            var password=$('input[name=password]');
            if(username.val()=="")
            {
            	layer.msg('用户名不能为空',{offset: ['475px', '47%']}); 
            	username.focus();
                return ;
            }

            if(password.val()=="")
            {     

            	layer.msg('密码不能为空',{offset: ['475px', '47%']}); 
                password.focus();
                return ;
            }

             var formData = new FormData($("#myform")[0]);//获取表单数据        
          $.ajax({
               url: "${pageContext.request.contextPath}/loginfun.action",//提交地址
               type: 'POST',
               data: formData,
               async: false,
               cache: false,
               contentType: false,
               processData: false,
               success: function (returndata) {
                if(returndata.code=='1'){
					if(returndata.data.usertype==1)
                   		window.location.href="${pageContext.request.contextPath}/main/main.action";
                    else
                    	window.location.href="${pageContext.request.contextPath}/jwc/main/main.action";
                }
                else
                layer.msg(returndata.message,{
                    offset: ['475px', '47%']
                });          
               },
               error: function (returndata) {
                layer.msg(returndata.message,{
                    offset: ['475px', '47%']
                }); 

           }
          });     

        });


</script>
</html>